/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package dominio;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author jair
 */
@Entity
@Table(name = "Matricula")
public class Matricula implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @NotNull
    @Column(name = "CODMATRICULA")
    private Integer id;

    @NotNull
    @Column(name = "Data_Matricula")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataMatricula;
   
    @Column(name = "Data_cancelamento")
    @Temporal(TemporalType.TIMESTAMP)
    private Date datacancelamento;
    
    @NotNull
    @Size(min = 1, max = 5)
    @Column(name = "Tipo_Matricula")
    private String tipoMatricula;
    
    @NotNull
    @Size(min = 1, max = 4)
    @Column(name = "Periodo")
    private String periodo;
    
    @Size(max = 20)
    @Column(name = "SituacaoFinal")
    private String situacaoFinal;
    
    @ManyToOne()
    @JoinColumn(name = "rgaluno")
    private Aluno aluno;
   
    @OneToMany(mappedBy = "matricula", fetch = FetchType.LAZY)
    private Set<Notas> notas = new HashSet<>();

    public Matricula() {
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getDataMatricula() {
        return dataMatricula;
    }

    public void setDataMatricula(Date dataMatricula) {
        this.dataMatricula = dataMatricula;
    }

    public Date getDatacancelamento() {
        return datacancelamento;
    }

    public void setDatacancelamento(Date datacancelamento) {
        this.datacancelamento = datacancelamento;
    }

    public String getTipoMatricula() {
        return tipoMatricula;
    }

    public void setTipoMatricula(String tipoMatricula) {
        this.tipoMatricula = tipoMatricula;
    }

    public String getPeriodo() {
        return periodo;
    }

    public void setPeriodo(String periodo) {
        this.periodo = periodo;
    }

    public String getSituacaoFinal() {
        return situacaoFinal;
    }

    public void setSituacaoFinal(String situacaoFinal) {
        this.situacaoFinal = situacaoFinal;
    }

    public Aluno getAluno() {
        return aluno;
    }

    public void setAluno(Aluno aluno) {
        this.aluno = aluno;
    }

    public Set<Notas> getNotas() {
        return notas;
    }

    public void setNotas(Set<Notas> notas) {
        this.notas = notas;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 23 * hash + Objects.hashCode(this.id);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Matricula other = (Matricula) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        return true;
    }

    
}
